package com.creative.accountsdk.net.account;

import com.creative.accountsdk.UmsChannel;
import com.creative.accountsdk.UserData;
import com.creative.accountsdk.net.Protocol;
import com.creative.accountsdk.net.XParams;
import com.loopj.android.http.RequestParams;

import org.json.JSONArray;
import org.json.JSONObject;

/**
 * Created by wang_qian on 2015/11/28.
 */
public class ChildBindParentProtocol extends Protocol {
    private String parentInviteCode;
    private UserData    userData;
    public JSONObject  parentJson;

    public  ChildBindParentProtocol(String inviteCode) {
        parentInviteCode = inviteCode;
        userData = UserData.getInstance();

    }
    @Override
    public RequestParams getParams() {
        return new XParams()
                .put("uid", userData.getUid())
                .put("qrcode",parentInviteCode)
                .put(UmsChannel.PARAM_NAME, UmsChannel.getChannel())
                .getParams();
    }

    @Override
    public String getUrl() {
        return getUrlPrefix()+"ui/bind/parent";
    }

    @Override
    protected void parseReturnMap(JSONObject returnMap) {
            if (returnMap.has("parent")) {
                parentJson = returnMap.optJSONObject("parent");
            }

    }
}
